package com.gitee.melin.bee.core.conf;

import lombok.Data;
import org.apache.commons.lang3.StringUtils;

import java.util.Set;

/**
 * @author melin
 */
@Data
public class ConfigEntry<T> {
    private String key;
    private String doc;
    private String version;
    private Set<T> validValues;
    private T defaultValue;

    public ConfigEntry(String key, String doc, String version, T defaultValue) {
        this.key = key;
        this.doc = doc;
        this.version = version;
        this.defaultValue = defaultValue;
    }

    public ConfigEntry<T> setDefaultValue(T defaultValue) {
        this.defaultValue = defaultValue;
        return this;
    }

    @Override
    public String toString() {
        return "ConfigEntry{" +
                "key='" + key + '\'' +
                ", version='" + version + '\'' +
                ", validValues=" + StringUtils.join(validValues, ",") +
                ", defaultValue=" + defaultValue +
                ", doc='" + doc + '\'' +
                '}';
    }
}
